﻿<%@ Page Title="Mobilhjulskift.dk - Aktivering af rabatkode" Language="C#" MasterPageFile="~/WebsiteSub.master" AutoEventWireup="true" CodeBehind="Rabatkode.aspx.cs" Inherits="TireService.Website.Rabatkode" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <meta name="description" content="Aktivering af rabatkode." />
    <meta name="keywords" content="rabat tilbud hjulskift bestil dæk mobil abonnement" />

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">

    <dx:ASPxLoadingPanel ID="LoadingPanel" Text="Vent venligst..." ClientInstanceName="LoadingPanel" runat="server" Modal="True">
    </dx:ASPxLoadingPanel>

    <!-- Javascript: Select ZipCode -->
    <script language="javascript" type="text/javascript">

        // Function that will activate quotationcode
        function LoadVoucher() {
            // Validate value
            txtVoucher.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("Voucher");
            if (isFormValid) {
                // Form is valid - show free dates

                // Prepare input (0: Voucher)
                var input = txtVoucher.GetText();

                // Do server postback
                callbackVoucherPanel.PerformCallback(input);

                // Show loadingpanel while doing server postback
                LoadingPanel.Show();
            }
        }

        function OnCallbackLoadVoucherComplete(s, e) {
            // Hide loadingpanel in case it is running
            LoadingPanel.Hide();

            callbackVoucherPanel.SetVisible(true);
        }

        function CallBackError(s, e) {
            // Hide loadingpanel in case it is running
            LoadingPanel.Hide();

            callbackVoucherPanel.SetVisible(false);
        }

        function ActivateVoucher() {
            window.open('Bestilling.aspx?Voucher=' + txtVoucher.GetText(),'_self');
        }

    </script>

  <%--  <dx:ASPxCallback ID="callBackLoadVoucher" ClientInstanceName="callBackLoadVoucher" runat="server" OnCallback="callBackLoadVoucher_Callback">
        <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackLoadVoucherComplete" />
    </dx:ASPxCallback>--%>
    <div id="box1">
        <h1>Aktivering af rabatkode</h1>
        <p class="normaltext">
            Indtast din rabatkode nedenfor. <br />
        </p>
        <table>
            <tr>
                <td>
                    <dx:ASPxTextBox ID="txtVoucher" ClientInstanceName="txtVoucher" runat="server" Width="200px">
                        <ValidationSettings CausesValidation="true" ValidationGroup="Voucher" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast rabat-/tilbudskode" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                            <RequiredField IsRequired="True" ErrorText="Indtast rabat-/tilbudskode"></RequiredField>
                        </ValidationSettings>
                        <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) LoadVoucher();}" />
                    </dx:ASPxTextBox>
                </td>
                <td>
                    <dx:ASPxButton ID="btnLoadVoucher" ClientInstanceName="btnLoadVoucher" runat="server" Text="Valider kode" AutoPostBack="False" UseSubmitBehavior="False">
                        <ClientSideEvents Click="function(s, e) { LoadVoucher(); }" />
                    </dx:ASPxButton>
                </td>
            </tr>
        </table>
        <br />
        <dx:ASPxCallbackPanel ID="callbackVoucherPanel" ClientInstanceName="callbackVoucherPanel" runat="server" Width="100%" ClientVisible="false" OnCallback="callbackVoucherPanel_Callback" RenderMode="Table">
            <ClientSideEvents EndCallback="OnCallbackLoadVoucherComplete" CallbackError="CallBackError" />
            <PanelCollection>
                <dx:PanelContent>
                    <h2>Indhold af dit tilbud</h2>
                    <dx:ASPxGridView ID="gvVoucher" ClientInstanceName="gvVoucher" runat="server" AutoGenerateColumns="false" OnCustomUnboundColumnData="gvVoucher_CustomUnboundColumnData">
                        <Settings ShowPreview="true" />
                        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                        <SettingsBehavior AllowSort="false" ConfirmDelete="True" AllowGroup="false" AllowDragDrop="false" />
                        <Settings ShowFooter="True" />
                        <Columns>
                            <dx:GridViewDataColumn FieldName="SubscriptionId" Visible="false" VisibleIndex="0" Caption="SubscriptionId">
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="1" Caption="Produkt">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataColumn FieldName="Quantity" VisibleIndex="2" Caption="Antal">
                            </dx:GridViewDataColumn>
                            <dx:GridViewDataSpinEditColumn FieldName="OneTimeUnitPrice" VisibleIndex="3" Caption="Tilbuds pris">
                                <PropertiesSpinEdit DisplayFormatString="c"></PropertiesSpinEdit>
                            </dx:GridViewDataSpinEditColumn>
                            <dx:GridViewDataSpinEditColumn FieldName="NormalPrice" VisibleIndex="4" UnboundType="String" Caption="Normal pris" CellStyle-Font-Strikeout="true">
                                <PropertiesSpinEdit DisplayFormatString="c"></PropertiesSpinEdit>
                            </dx:GridViewDataSpinEditColumn>
                            <dx:GridViewDataSpinEditColumn FieldName="TotalPrice" VisibleIndex="5" Caption="Total pris">
                                <PropertiesSpinEdit DisplayFormatString="c"></PropertiesSpinEdit>
                            </dx:GridViewDataSpinEditColumn>

                            <%--<dx:GridViewDataColumn FieldName="TotalPriceValue" VisibleIndex="4" Caption="Total pris" UnboundType="String">
                            </dx:GridViewDataColumn>--%>
                        </Columns>
                        <TotalSummary>
                            <dx:ASPxSummaryItem FieldName="TotalPrice" SummaryType="Sum" />
                        </TotalSummary>
                    </dx:ASPxGridView>
                    <br />
                    <dx:ASPxButton ID="btnActivateVoucher" ClientInstanceName="btnActivateVoucher" runat="server" Text="Aktiver kode og gå til bestilling" AutoPostBack="False" UseSubmitBehavior="False">
                        <ClientSideEvents Click="function(s, e) { ActivateVoucher(); }" />
                    </dx:ASPxButton>
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxCallbackPanel>
    </div>
    
    

</asp:Content>
